home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 4.4 KB | 171 lines | [TEXT/CWIE] |
- // Release Version: $ ODF 1 $
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
-
- //================================================================================
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- // ----- Framework Layer -----
- #ifndef FWPRESEN_H
- #include "FWPresen.h" // FW_CPresentation
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h" // FW_Beep()
- #endif
-
- #ifndef FWABOUT_H
- #include "FWAbout.h" //::FW_About()
- #endif
-
- #ifndef FWFLOWIN_H
- #include "FWFloWin.h" // FW_CFloatingWindow
- #endif
-
- // ----- OS Layer -----
- #ifndef FWRESFIL_H
- #include "FWResFil.h" // FW_CResourceFile
- #endif
-
- #ifndef FWMENU_H
- #include "FWMenu.h" // FW_CMenuBar, FW_CPullDownMenu
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h" // FW_CSharedLibraryResourceFile
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h" // FW_CMenuEvent
- #endif
-
- #ifndef FWPICTUR_H
- #include "FWPictur.h" // FW_CPicture
- #endif
-
- //==============================================================================
- #ifdef FW_BUILD_MAC
- #pragma segment Windoid
- #endif
-
- FW_DEFINE_AUTO(CWindoidPart)
- //==============================================================================
- CWindoidPart::CWindoidPart(ODPart* odPart)
- : FW_CPart(odPart, FW_gInstance, kPartInfoID),
- fMainPresentation(NULL),
- fPalettePresentation(NULL),
- fPaletteWindow(NULL)
- {
- FW_END_CONSTRUCTOR
- }
-
- //--------------------------------------------------------------------------------
- CWindoidPart::~CWindoidPart()
- {
- FW_START_DESTRUCTOR
- }
-
- //--------------------------------------------------------------------------------
- void
- CWindoidPart::Initialize(Environment* ev) // Override
- {
- FW_DO_NOT_DEAD_STRIP(FW_CToggleItem);
-
- FW_CPart::Initialize(ev);
- const FW_Boolean kDefault = TRUE;
- const ODType kMainPresentation = "Apple:Presentation:Main";
- const ODType kPalettePresentation = "Apple:Presentation:Palette";
- fMainPresentation = this->RegisterPresentation(ev, kMainPresentation, kDefault);
- fPalettePresentation = this->RegisterPresentation(ev, kPalettePresentation, !kDefault);
- FW_CSharedLibraryResourceFile resFile(ev);
- GetMenuBar(ev)->InitializeFromResource(ev, kMenuBarID);
- }
-
- //--------------------------------------------------------------------------------
- FW_Boolean
- CWindoidPart::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus,
- FW_Boolean isRoot) // Override
- {
- if (hasMenuFocus) {
- menuBar->EnableAndToggleCommand(ev, cShowHideCommand, true,
- fPaletteWindow == NULL || !fPaletteWindow->IsShown(ev));
- }
- return FALSE;
- }
-
- //--------------------------------------------------------------------------------
- FW_Boolean
- CWindoidPart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent) // Override
- {
- FW_Boolean menuHandled = true;
- switch (theMenuEvent.GetCommandID(ev))
- {
- case kODCommandAbout:
- ::FW_About(ev, this, kAbout);
- break;
-
- case cShowHideCommand:
- fPaletteWindow->ShowHide(ev, ! fPaletteWindow->IsShown(ev));
- break;
-
- default:
- menuHandled = false;
- }
- return menuHandled;
- }
-
- //--------------------------------------------------------------------------------
- FW_CFrame*
- CWindoidPart::NewFrame(Environment* ev, ODFrame* odFrame,
- FW_CPresentation* presentation, FW_Boolean fromStorage) // Override
- {
- FW_UNUSED(fromStorage);
- if (presentation == fPalettePresentation) {
- return FW_NEW( CPaletteFrame, (ev, odFrame, presentation, this) );
- }
- return FW_NEW( CMainFrame, (ev, odFrame, presentation, this) );
- }
-
- //------------------------------------------------------------------------------
- FW_CContent*
- CWindoidPart::NewPartContent(Environment* ev)
- {
- return NULL;
- }
-
- //--------------------------------------------------------------------------------
- void
- CWindoidPart::MyMakePalette(Environment* ev, FW_Boolean showWindow)
- {
- if (fPaletteWindow == NULL)
- {
- FW_CSharedLibraryResourceFile resFile(ev); // palette picture here
- FW_CPicture picture(resFile, kPalettePictID);
- FW_CRect bounds;
- picture.GetPictBounds(bounds);
- FW_CPoint windowSize = bounds.Size();
- FW_CPoint windowPosition(FW_IntToFixed(100), FW_IntToFixed(100));
- const FW_Boolean kWantCloseBox = true;
- const FW_CString32 kWindowTitle("");
- fPaletteWindow = new FW_CFloatingWindow(ev, this,
- fPalettePresentation, kWindowTitle,
- windowSize, windowPosition, kWantCloseBox);
- if (showWindow)
- fPaletteWindow->Show(ev);
- }
- }
-